<template>
	<!-- 延期审批 -->
	<view class="p-10">
		<u-sticky class="p-10" style="background-color: #fff;">
			<u-subsection :list="tabList" activeColor="#2172FC" :current="currentKey" mode="subsection"
				@change="handleTabClick"></u-subsection>
		</u-sticky>
		<template v-if="list.length > 0">
			<view class="card" v-for="(item,index) in list" @click="goDetail(item)">
				<view class="flex m-between">
					<view class="name fw">
						申请人: {{item.applyUserName}}
					</view>
					<view class="grade fw"> 申请次数: {{item.applyCount}}
					</view>
				</view>
				<view class="flex m-between m-t-8"> 申请原因: <up-text :lines="2" :text="item.applyMessage"></up-text>
				</view>
				<view class="flex m-between m-t-8">
					<view class="post"> 地点: {{item.riskLocationName}}
					</view>
					<view class="pro"> 隐患等级: {{item.hiddenLevelName}}
					</view>
				</view>
				<view class="flex m-between m-t-8">
					<view class="post"> 上报日期: {{item.uploadDate}}
					</view>
					<view class="pro"> 原限制日期: {{item.requireChangeEndDate}}
					</view>
				</view>
				<view class="flex m-between m-t-8">
					<view class="post"> 申请限制日期: {{item.applyChangeDate}}
					</view>
					<view class="pro"> 受理人: {{item.examinUserName}}
					</view>
				</view>
			</view>
		</template>
		<u-empty v-else mode="data">
		</u-empty>
	</view>
	<u-back-top :scroll-top="scrollTop" top="600"></u-back-top>
</template>
<script setup>
	import {
		onShow
	} from '@dcloudio/uni-app'
	import {
		reactive,
		ref,
	} from "vue";
	import {
		pageApprove
	} from '@/api/hidden-danger.js'
	import Dict from '@/store/dict.js'
	import useList from '@/hooks/useList.js'

	const dict = Dict()
	let currentKey = ref(0),
		queryParams = reactive({
			needCount: 1,
			pageNum: 1,
			pageSize: 10,
			state: 0,
		}),
		tabList = [{
			name: '未审核',
		}, {
			name: '已审核',
		}]
	const handleTabClick = (index) => {
		currentKey.value = index
		queryParams.state = index
		queryParams.pageNum = 1
		getListData()
	}
	// 跳转详情
	const goDetail = (item) => {
		uni.navigateTo({
			url: '/pages/professional/hiddenTrouble/approve/detailInfo?data=' + JSON.stringify(item) +
				'&currentKey=' + currentKey.value
		})
	}
	// 字典数据
	const getDicts = () => {
		dict.GETspecialtyKey()
	}
	const {
		getListData,
		getCheckPonit,
		list,
		scrollTop,
	} = useList({
		queryParams,
		api: {
			page: pageApprove
		}
	})
	// 初始化数据
	const init = () => {
		getListData()
		getDicts()
		getCheckPonit()
	}
	onShow(() => {
		init()
	})
</script>
<style lang="scss" scoped>
</style>